<#import "/admin/_layout.html" as layout>
<@layout.header "分类管理"></@layout.header>
<@layout.body>
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-left">
                        <li class="breadcrumb-item"><a href="#">分类</a></li>
                        <li class="breadcrumb-item active">列表</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <section class="content">
    <div class="container-fluid">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <a href="/admin/product/category/edit" class="btn btn-info"><i class="fas fa-plus"></i> 新增</a>
                </div>
                <table class="table table-hover" style="width:100%">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>分类名称</th>
                        <th>类型</th>
                        <th>排序</th>
                        <th>创建人</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <#list pageData.records as item>
                        <tr>
                            <td>${item.id!}</td>
                            <td><a href="${item.url!}" target="_blank">${item.title!}</a></td>
                            <td>
                                <#if item.type=='category'>
                                    分类
                                <#elseif item.type="tag">
                                    标签
                                <#else>
                                    item.type
                                </#if>
                            </td>
                            <td>${(item.sortNum)!}</td>
                            <td>${(item.createdUser)!}</td>
                            <td><a href="/admin/product/category/edit?id=${item.id!?c}">编辑</a>
                                <a class="del_a" href="javascript:void(0)" id="${item.id!?c}">删除</a>
                            </td>
                        </tr>
                    </#list>
                </table>
                <@layout._adminPage/>
            </div>
        </div>
    </div>
    </section>
</@layout.body>
<@layout.script>
    <script>
        $(".del_a").click(function() {
            var id = $(this).attr("id");
            layer.confirm('确定要删除分类吗?', {
                btn : ['确定', '取消']
            }, function(i) {
                layer.close(i);
                ajaxPost("/admin/product/category/doDelete", {id: id}, function () {
                    alertSuccess("删除成功", function(){
                        location.href = "/admin/product/category/list";
                    })
                })
            });
        })
    </script>
</@layout.script>